unit uRelatorioRecebimentosPeriodo;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, cxGraphics, cxControls, cxLookAndFeels, cxLookAndFeelPainters,
  cxStyles, dxSkinsCore, dxSkinBlack, dxSkinBlue, dxSkinOffice2007Black,
  dxSkinOffice2007Blue, dxSkinOffice2007Green, dxSkinOffice2007Pink,
  dxSkinOffice2007Silver, 
  dxSkinscxPCPainter, cxCustomData, cxFilter, cxData,
  cxDataStorage, cxEdit, DB, cxDBData, StdCtrls, Buttons, cxGridLevel,
  cxClasses, cxGridCustomView, cxGridCustomTableView, cxGridTableView,
  cxGridDBTableView, cxGrid, dxPSGlbl, dxPSUtl, dxPSEngn, dxPrnPg, dxBkgnd,
  dxWrap, dxPrnDev, dxPSCompsProvider, dxPSFillPatterns, dxPSEdgePatterns,
  dxPSPDFExportCore, dxPSPDFExport, cxDrawTextUtils, dxPSPrVwStd, dxPSPrVwAdv,
  dxPSPrVwRibbon, dxPScxPageControlProducer, dxPScxEditorProducers,
  dxPScxExtEditorProducers, dxSkinsdxBarPainter, dxSkinsdxRibbonPainter,
  dxPgsDlg, dxPrnDlg, dxPSCore, dxPScxGrid6Lnk, dxPSDBBasedXplorer,
  dxBarSkinnedCustForm, dxPScxCommon, ZAbstractRODataset, ZAbstractDataset,
  ZAbstractTable, ZDataset, dxSkinOffice2010Black, dxSkinOffice2010Blue,
  dxSkinOffice2010Silver, uReportDatamodule;

type
  TFRelatorioRecebimentosPeriodo = class(TForm)
    btn_Imprimir: TBitBtn;
    dxPrinter1: TdxComponentPrinter;
    dxEngController: TdxPSEngineController;
    cxgrdRecebimentosPeriodo: TcxGrid;
    gdRecebimentosPeriodo: TcxGridDBTableView;
    cxgrdlvlRecebimentosPeriodo: TcxGridLevel;
    btn_VizualizarImpressao: TBitBtn;
    dxgrdrprtlnkPrinter1Link1: TdxGridReportLink;
    lbl37: TLabel;
    cxStyleRepository1: TcxStyleRepository;
    cxStyle1: TcxStyle;
    cxStyle2: TcxStyle;
    procedure btn_ImprimirClick(Sender: TObject);
    procedure btn_VizualizarImpressaoClick(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
  private
    { Private declarations }
  public
    { Public declarations }
    procedure load(dataInicial: string; dataFinal: string);
  end;

var
  FRelatorioRecebimentosPeriodo: TFRelatorioRecebimentosPeriodo;

implementation

uses uDataModule;

{$R *.dfm}

procedure TFRelatorioRecebimentosPeriodo.btn_ImprimirClick(Sender: TObject);
begin
  dxPrinter1.Print(True,nil);
end;

procedure TFRelatorioRecebimentosPeriodo.btn_VizualizarImpressaoClick(Sender: TObject);
begin
  dxPrinter1.preview(True, nil);
end;

procedure TFRelatorioRecebimentosPeriodo.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  dmreport.Free;
end;

procedure TFRelatorioRecebimentosPeriodo.load(dataInicial: string; dataFinal: string);
var
  AItemList: TcxFilterCriteriaItemList;
begin
  gdRecebimentosPeriodo.DataController.BeginUpdate;
  dmreport := Tdmreport.Create(Application);
  dmreport.loadRecebimentosPeriodo(dataInicial, dataFinal);
  gdRecebimentosPeriodo.DataController.CreateAllItems();
  gdRecebimentosPeriodo.DataController.EndUpdate;
  gdRecebimentosPeriodo.ApplyBestFit();
  gdRecebimentosPeriodo.DataController.Refresh;


  gdRecebimentosPeriodo.DataController.Filter.BeginUpdate;
  gdRecebimentosPeriodo.DataController.Filter.Root.Clear;
  AItemList := gdRecebimentosPeriodo.DataController.Filter.Root.AddItemList(fboAnd);
  AItemList.AddItem( gdRecebimentosPeriodo.Columns[6], foEqual, datamodule1.CurrentUser , inttostr(datamodule1.CurrentUser));
  gdRecebimentosPeriodo.DataController.Filter.EndUpdate;
  gdRecebimentosPeriodo.DataController.Filter.Active := true;
end;

end.
